package com.mew.chess.core.game.pokdeng.game;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


/**游戏管理类  单例 房间列表
 * @author dylin
 */
public class PokDengGameManager {

    private int gameId;
    private static PokDengGameManager bjlGameManager = new PokDengGameManager();
    private final Map<Integer, PokDengRoomManager> controllerMap = new ConcurrentHashMap<>(8);

    private PokDengGameManager(){
    }

    public static PokDengGameManager getInstance() {
        if (bjlGameManager == null) {
            synchronized (PokDengGameManager.class) {
                if (bjlGameManager == null) {
                    bjlGameManager = new PokDengGameManager();
                }
            }
        }
        return bjlGameManager;
    }


    public void putController(PokDengRoomManager controller){
        controllerMap.put(controller.getRoomId(), controller);
    }

    public PokDengRoomManager getController(Integer roomId){
        return controllerMap.get(roomId);
    }

    public int getGameId() {
        return gameId;
    }

    public void setGameId(int gameId) {
        this.gameId = gameId;
    }

}
